using System.Linq.Expressions;

namespace DealerPlatform.Core.Repository;

public interface IRepository<TEntity> where TEntity : class
{
    List<TEntity> GetList();
    List<TEntity> GetList(Func<TEntity, bool> predicate);
    Task<List<TEntity>> GetListAsync();
    Task<List<TEntity>> GetListAsync(PageWithSortDto pageWithSortDto);
    IQueryable<TEntity> GetQueryable();
    Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate);
    TEntity Get(Func<TEntity, bool> predicate);
    Task<TEntity> GetAsync(Expression<Func<TEntity, bool>> predicate);

    Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate,
        string sort,
        int pageIndex,
        int pageSize);
    TEntity Insert(TEntity entity);
    Task<TEntity> InsertAsync(TEntity entity);
    TEntity Update(TEntity entity);
    Task<TEntity> UpdateAsync(TEntity entity);
    TEntity Delete(TEntity entity);    
    Task<TEntity> DeleteAsync(TEntity entity);
}